package gov.pbc.nn.kjgl.item.template.handler;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.bstek.uflo.env.Context;
import com.bstek.uflo.model.ProcessInstance;
import com.bstek.uflo.process.handler.ProcessEventHandler;

@Component(SubProcessEventHandler.BEAN_ID)
public class SubProcessEventHandler implements ProcessEventHandler {

	public static final String BEAN_ID = "gov.pbc.nn.kjgl.item.template.handler.SubProcessEventHandler";

	@Override
	public void end(ProcessInstance arg0, Context arg1) {

	}

	@Override
	public void start(ProcessInstance pi, Context context) {
		long parentId = pi.getParentId();
		Object nextDept = context.getProcessService().getProcessVariable("nextDept", parentId);

		Map<String, Object> variables = new HashMap<String, Object>();
		variables.put("stamped", false);
		variables.put("agree", 0);
		variables.put("collectUsers", Collections.EMPTY_LIST);
		variables.put("withdrawUsers", Collections.EMPTY_LIST);
		variables.put("currentDept", nextDept);
		context.getProcessService().saveProcessVariables(pi.getId(), variables);
	}

}
